<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>行情接口Python文档.md</title><link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext' rel='stylesheet' type='text/css'><style type='text/css'>html, body {overflow-x: initial !important;}.CodeMirror { height: auto; }
.CodeMirror-scroll { overflow-y: hidden; overflow-x: auto; }
.CodeMirror-lines { padding: 4px 0px; }
.CodeMirror pre { }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background-color: white; }
.CodeMirror-gutters { border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); white-space: nowrap; background-color: rgb(247, 247, 247); }
.CodeMirror-linenumbers { }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.CodeMirror div.CodeMirror-cursor { border-left-width: 1px; border-left-style: solid; border-left-color: black; z-index: 3; }
.CodeMirror div.CodeMirror-secondarycursor { border-left-width: 1px; border-left-style: solid; border-left-color: silver; }
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { width: auto; border: 0px; z-index: 1; background: rgb(119, 238, 119); }
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite { }
.cm-tab { display: inline-block; }
.cm-s-typora-default .cm-header, .cm-s-typora-default .cm-property { color: rgb(217, 79, 138); }
.cm-s-typora-default pre.cm-header1:not(.cm-atom) :not(.cm-overlay) { font-size: 2rem; line-height: 2rem; }
.cm-s-typora-default pre.cm-header2:not(.cm-atom) :not(.cm-overlay) { font-size: 1.4rem; line-height: 1.4rem; }
.cm-s-typora-default .cm-atom, .cm-s-typora-default .cm-number { color: rgb(149, 132, 134); }
.cm-s-typora-default .cm-table-row, .cm-s-typora-default .cm-block-start { font-family: monospace; }
.cm-s-typora-default .cm-comment { color: rgb(74, 90, 159); font-family: monospace; }
.cm-s-typora-default .cm-tag { color: rgb(169, 68, 66); }
.cm-s-typora-default .cm-string { color: rgb(126, 134, 169); }
.cm-s-typora-default .cm-link { color: rgb(196, 122, 15); text-decoration: underline; }
.cm-s-typora-default .cm-variable-2, .cm-s-typora-default .cm-variable-1 { color: inherit; }
.cm-s-typora-default .cm-overlay { font-size: 1rem; font-family: monospace; }
.CodeMirror.cm-s-typora-default div.CodeMirror-cursor { border-left-width: 3px; border-left-style: solid; border-left-color: rgb(228, 98, 154); }
.cm-s-typora-default .CodeMirror-activeline-background { left: -60px; right: -30px; background: rgba(204, 204, 204, 0.2); }
.cm-s-typora-default .CodeMirror-gutters { border-right-style: none; background-color: inherit; }
.cm-s-typora-default .cm-trailing-space-new-line::after, .cm-startspace::after, .cm-starttab .cm-tab::after { content: "•"; position: absolute; left: 0px; opacity: 0; font-family: LetterGothicStd, monospace; }
.os-windows .cm-startspace::after, .os-windows .cm-starttab .cm-tab::after { left: -0.1em; }
.cm-starttab .cm-tab::after { content: " "; }
.cm-startspace, .cm-tab, .cm-starttab, .cm-trailing-space-a, .cm-trailing-space-b, .cm-trailing-space-new-line { font-family: monospace; position: relative; }
.cm-s-typora-default .cm-trailing-space-new-line::after { content: "↓"; opacity: 0.3; }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: black; }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-property { color: black; }
.cm-s-inner .cm-operator { color: black; }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: blue; }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: bold; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: rgb(255, 0, 0); }
.cm-invalidchar { color: rgb(255, 0, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.CodeMirror-activeline-background { background: rgb(232, 242, 255); }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { margin-bottom: -30px; margin-right: -30px; padding-bottom: 30px; padding-right: 30px; height: 100%; outline: none; position: relative; box-sizing: content-box; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow-x: hidden; overflow-y: scroll; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow-y: hidden; overflow-x: scroll; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-radius: 0px; border-width: 0px; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; word-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; background: transparent; }
.CodeMirror-wrap pre { word-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right-width: 30px; border-right-style: solid; border-right-color: transparent; width: fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right-style: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-widget { }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right-style: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.CodeMirror-selected { background: rgb(217, 217, 217); }
.CodeMirror-focused .CodeMirror-selected { background: rgb(215, 212, 240); }
.cm-searching { background: rgba(255, 255, 0, 0.4); }
.CodeMirror span { }
@media print { 
  .CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}


html { font-size: 14px; }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1rem; line-height: 1.42857; color: rgb(51, 51, 51); overflow-x: hidden; background-color: rgb(255, 255, 255); }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { text-shadow: none; background: rgb(181, 214, 252); }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; padding-bottom: 70px; white-space: pre-wrap; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
.typora-export #write { margin: 0px auto; }
#write > p:first-child, #write > ul:first-child, #write > ol:first-child, #write > pre:first-child, #write > blockquote:first-child, #write > div:first-child, #write > table:first-child { margin-top: 30px; }
img { max-width: 100%; }
input, button, select, textarea { color: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
::before, ::after, * { box-sizing: border-box; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write div, #write pre { width: inherit; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6 { position: relative; }
h1 { font-size: 2rem; }
p { -webkit-margin-before: 1rem; -webkit-margin-after: 1rem; -webkit-margin-start: 0px; -webkit-margin-end: 0px; }
.mathjax-block { margin-top: 0px; margin-bottom: 0px; -webkit-margin-before: 0rem; -webkit-margin-after: 0rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: bold; font-style: italic; }
a { cursor: pointer; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; margin: 4px 0px 0px; }
tr { page-break-inside: avoid; page-break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; page-break-inside: auto; }
table.md-table td { min-width: 80px; }
.CodeMirror-gutters { border-right-width: 0px; background-color: inherit; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
pre { white-space: pre-wrap; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences, pre.md-fences { font-size: 0.9rem; display: block; page-break-inside: avoid; text-align: left; overflow: visible; white-space: pre; position: relative !important; background: inherit; }
.md-fences .CodeMirror.CodeMirror-wrap { top: -1.6em; margin-bottom: -1.6em; }
.md-fences.mock-cm { white-space: pre-wrap; }
.show-fences-line-number pre.md-fences { padding-left: 0px; }
.show-fences-line-number pre.md-fences.mock-cm { padding-left: 40px; }
.footnotes { color: rgb(136, 136, 136); font-size: 0.9rem; padding-top: 1em; padding-bottom: 1em; }
.footnotes + .footnotes { margin-top: -1em; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; text-decoration: none; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1rem; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; -webkit-tap-highlight-color: transparent; line-height: normal; font-weight: normal; text-align: left; box-sizing: content-box; direction: ltr; background: transparent; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li p, li .mathjax-block { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; }
@media print { 
  html, body { height: 100%; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  h1, h2, h3, h4, h5, h6 { page-break-after: avoid; orphans: 2; }
  p { orphans: 4; }
  @page { margin: 20mm 0mm; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
#write pre.md-meta-block { font-size: 0.8rem; min-height: 2.86rem; white-space: pre-wrap; display: block; background: rgb(204, 204, 204); }
p > .md-image:only-child { display: inline-block; width: 100%; text-align: center; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.mathjax-block { white-space: pre; overflow: hidden; width: 100%; }
p + .mathjax-block { margin-top: -1.143rem; }
.mathjax-block:not(:empty)::after { display: none; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: none; box-shadow: none; }
.task-list { list-style-type: none; }
.task-list-item { position: relative; padding-left: 1em; }
.task-list-item input { position: absolute; top: 0px; left: 0px; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc::after, .md-toc-content::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); text-decoration: none; }
.md-toc-inner:hover { text-decoration: underline; }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: bold; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
.md-toc-h6 { margin-left: 12em; }
@media screen and (max-width: 48em) { 
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 8em; }
  .md-toc-h6 { margin-left: 9.5em; }
}
a.md-toc-inner { color: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; text-decoration: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
.md-tag { opacity: 0.5; }
code { text-align: left; }
h1 .md-tag, h2 .md-tag, h3 .md-tag, h4 .md-tag, h5 .md-tag, h6 .md-tag { font-weight: initial; opacity: 0.35; }
a.md-header-anchor.md-print-anchor { border: none !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: none !important; text-decoration: initial !important; text-shadow: initial !important; background: transparent !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.mathjax-block .MathJax_SVG_Display { text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-width: 0px; min-height: 0px; width: 100%; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: monospace; }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: normal; line-height: normal; font-size: 100%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { transition: none; }


@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: normal; src: local(Open Sans Regular), url(file:///C:/Users/admin/AppData/Roaming/Typora/themes/github/400.woff) format(woff); }
@font-face { font-family: 'Open Sans'; font-style: italic; font-weight: normal; src: local(Open Sans Italic), url(file:///C:/Users/admin/AppData/Roaming/Typora/themes/github/400i.woff) format(woff); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: bold; src: local(Open Sans Bold), url(file:///C:/Users/admin/AppData/Roaming/Typora/themes/github/700.woff) format(woff); }
@font-face { font-family: 'Open Sans'; font-style: italic; font-weight: bold; src: local(Open Sans Bold Italic), url(file:///C:/Users/admin/AppData/Roaming/Typora/themes/github/700i.woff) format(woff); }
html { font-size: 16px; }
body { font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; color: rgb(51, 51, 51); line-height: 1.6; -webkit-font-smoothing: antialiased; }
#write { max-width: 800px; margin: 0px auto; padding: 20px 30px 40px; }
#write::after { height: 80px; }
#write > ul:first-child, #write > ol:first-child { margin-top: 30px; }
body > :first-child { margin-top: 0px !important; }
body > :last-child { margin-bottom: 0px !important; }
a { color: rgb(65, 131, 196); }
h1, h2, h3, h4, h5, h6 { position: relative; margin-top: 1rem; margin-bottom: 1rem; font-weight: bold; line-height: 1.4; -webkit-font-smoothing: antialiased; cursor: text; }
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor { text-decoration: none; }
h1 tt, h1 code { font-size: inherit; }
h2 tt, h2 code { font-size: inherit; }
h3 tt, h3 code { font-size: inherit; }
h4 tt, h4 code { font-size: inherit; }
h5 tt, h5 code { font-size: inherit; }
h6 tt, h6 code { font-size: inherit; }
h1 { padding-bottom: 0.3em; font-size: 2.25em; line-height: 1.2; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); }
h2 { padding-bottom: 0.3em; font-size: 1.75em; line-height: 1.225; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); }
h3 { font-size: 1.5em; line-height: 1.43; }
h4 { font-size: 1.25em; }
h5 { font-size: 1em; }
h6 { font-size: 1em; color: rgb(119, 119, 119); }
p, blockquote, ul, ol, dl, table { margin: 0.8em 0px; }
li > ol, li > ul { margin: 0px; }
hr { height: 4px; padding: 0px; margin: 16px 0px; border-width: 0px 0px 1px; border-style: none none solid; overflow: hidden; box-sizing: content-box; border-bottom-color: rgb(221, 221, 221); background-color: rgb(231, 231, 231); }
body > h2:first-child { margin-top: 0px; padding-top: 0px; }
body > h1:first-child { margin-top: 0px; padding-top: 0px; }
body > h1:first-child + h2 { margin-top: 0px; padding-top: 0px; }
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child { margin-top: 0px; padding-top: 0px; }
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 { margin-top: 0px; padding-top: 0px; }
h1 p, h2 p, h3 p, h4 p, h5 p, h6 p { margin-top: 0px; }
li p.first { display: inline-block; }
ul, ol { padding-left: 30px; }
ul:first-child, ol:first-child { margin-top: 0px; }
ul:last-child, ol:last-child { margin-bottom: 0px; }
blockquote { border-left-width: 4px; border-left-style: solid; border-left-color: rgb(221, 221, 221); padding: 0px 15px; color: rgb(119, 119, 119); }
blockquote blockquote { padding-right: 0px; }
table { padding: 0px; }
table tr { border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204); margin: 0px; padding: 0px; background-color: white; }
table tr:nth-child(2n) { background-color: rgb(248, 248, 248); }
table tr th { font-weight: bold; border: 1px solid rgb(204, 204, 204); text-align: left; margin: 0px; padding: 6px 13px; }
table tr td { border: 1px solid rgb(204, 204, 204); text-align: left; margin: 0px; padding: 6px 13px; }
table tr th:first-child, table tr td:first-child { margin-top: 0px; }
table tr th:last-child, table tr td:last-child { margin-bottom: 0px; }
.CodeMirror-gutters { border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); }
pre.md-fences, .md-fences, code, tt { border: 1px solid rgb(221, 221, 221); border-radius: 3px; font-family: Consolas, 'Liberation Mono', Courier, monospace; padding: 2px 4px 0px; font-size: 0.9em; background-color: rgb(248, 248, 248); }
pre.md-fences, .md-fences { margin-bottom: 15px; margin-top: 15px; padding: 8px 1em 6px; }
.task-list { padding-left: 0px; }
.task-list-item { padding-left: 32px; }
.task-list-item input { top: 3px; left: 8px; }
@media screen and (min-width: 914px) { 
}
@media print { 
  table, pre { page-break-inside: avoid; }
  pre { word-wrap: break-word; }
}
.md-fences { background-color: rgb(248, 248, 248); }
#write pre.md-meta-block { padding: 1rem; font-size: 85%; line-height: 1.45; border: 0px; border-radius: 3px; color: rgb(119, 119, 119); margin-top: 0px !important; background-color: rgb(247, 247, 247); }
.mathjax-block > .code-tooltip { bottom: 0.375rem; }
#write > h3.md-focus::before { left: -1.5625rem; top: 0.375rem; }
#write > h4.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
#write > h5.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
#write > h6.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
.md-image > .md-meta { border: 1px solid rgb(221, 221, 221); border-radius: 3px; font-family: Consolas, 'Liberation Mono', Courier, monospace; padding: 2px 4px 0px; font-size: 0.9em; color: inherit; background-color: rgb(248, 248, 248); }
.md-tag { color: inherit; }
.md-toc { margin-top: 20px; padding-bottom: 20px; }
#typora-quick-open { border: 1px solid rgb(221, 221, 221); background-color: rgb(248, 248, 248); }
#typora-quick-open-item { border-color: rgb(254, 254, 254) rgb(229, 229, 229) rgb(229, 229, 229) rgb(238, 238, 238); border-style: solid; border-width: 1px; background-color: rgb(250, 250, 250); }


</style>
</head>
<body class='typora-export' >
<div  id='write'  class = 'is-node'><div class='md-toc' mdtype='toc'><p class="md-toc-content"><span class="md-toc-item md-toc-h1" data-ref="c6"><a class="md-toc-inner" href="#header-c6">接口概要</a></span><span class="md-toc-item md-toc-h1" data-ref="c63"><a class="md-toc-inner" href="#header-c63">接口列表</a></span><span class="md-toc-item md-toc-h2" data-ref="c64"><a class="md-toc-inner" href="#header-c64">上下文控制</a></span><span class="md-toc-item md-toc-h2" data-ref="c66"><a class="md-toc-inner" href="#header-c66">低频数据接口</a></span><span class="md-toc-item md-toc-h2" data-ref="c68"><a class="md-toc-inner" href="#header-c68">订阅接口</a></span><span class="md-toc-item md-toc-h2" data-ref="c71"><a class="md-toc-inner" href="#header-c71">高频数据接口</a></span><span class="md-toc-item md-toc-h2" data-ref="c73"><a class="md-toc-inner" href="#header-c73">回调处理基类</a></span><span class="md-toc-item md-toc-h1" data-ref="c77"><a class="md-toc-inner" href="#header-c77">接口说明</a></span><span class="md-toc-item md-toc-h2" data-ref="c79"><a class="md-toc-inner" href="#header-c79">参数类型定义</a></span><span class="md-toc-item md-toc-h2" data-ref="c267"><a class="md-toc-inner" href="#header-c267">错误码说明</a></span><span class="md-toc-item md-toc-h2" data-ref="c314"><a class="md-toc-inner" href="#header-c314">详细说明</a></span><span class="md-toc-item md-toc-h3" data-ref="c315"><a class="md-toc-inner" href="#header-c315">实例化上下文对象</a></span><span class="md-toc-item md-toc-h3" data-ref="c326"><a class="md-toc-inner" href="#header-c326">启动推送接收 start</a></span><span class="md-toc-item md-toc-h3" data-ref="c332"><a class="md-toc-inner" href="#header-c332">停止推送接收 stop</a></span><span class="md-toc-item md-toc-h3" data-ref="c338"><a class="md-toc-inner" href="#header-c338">设置异步回调处理对象 set_handler</a></span><span class="md-toc-item md-toc-h3" data-ref="c369"><a class="md-toc-inner" href="#header-c369">获取交易日 get_trading_days</a></span><span class="md-toc-item md-toc-h3" data-ref="c398"><a class="md-toc-inner" href="#header-c398">获取股票信息  get_stock_basicinfo</a></span><span class="md-toc-item md-toc-h3" data-ref="c450"><a class="md-toc-inner" href="#header-c450">获取复权因子 get_autype_list</a></span><span class="md-toc-item md-toc-h3" data-ref="c486"><a class="md-toc-inner" href="#header-c486">获取历史K线 get_history_kline</a></span><span class="md-toc-item md-toc-h3" data-ref="c537"><a class="md-toc-inner" href="#header-c537">获取市场快照 get_market_snapshot</a></span><span class="md-toc-item md-toc-h3" data-ref="c623"><a class="md-toc-inner" href="#header-c623">获取分时数据  get_rt_data</a></span><span class="md-toc-item md-toc-h3" data-ref="c657"><a class="md-toc-inner" href="#header-c657">获取板块集合下的子板块列表 get_plate_list</a></span><span class="md-toc-item md-toc-h3" data-ref="c704"><a class="md-toc-inner" href="#header-c704">获取板块下的股票列表  get_plate_stock</a></span><span class="md-toc-item md-toc-h3" data-ref="c773"><a class="md-toc-inner" href="#header-c773">获取经纪队列  get_broker_queue</a></span><span class="md-toc-item md-toc-h3" data-ref="c804"><a class="md-toc-inner" href="#header-c804">获取牛牛程序全局状态  get_global_state</a></span><span class="md-toc-item md-toc-h3" data-ref="c895"><a class="md-toc-inner" href="#header-c895">订阅 subscribe</a></span><span class="md-toc-item md-toc-h3" data-ref="c924"><a class="md-toc-inner" href="#header-c924">退订 unsubscribe</a></span><span class="md-toc-item md-toc-h3" data-ref="c954"><a class="md-toc-inner" href="#header-c954">查询订阅 query_subscription</a></span><span class="md-toc-item md-toc-h3" data-ref="c969"><a class="md-toc-inner" href="#header-c969">获取报价   get_stock_quote 和 StockQuoteHandlerBase</a></span><span class="md-toc-item md-toc-h3" data-ref="c1020"><a class="md-toc-inner" href="#header-c1020">获取逐笔   get_rt_ticker 和 TickerHandlerBase</a></span><span class="md-toc-item md-toc-h3" data-ref="c1076"><a class="md-toc-inner" href="#header-c1076">获取实时K线    get_cur_kline 和 CurKlineHandlerBase</a></span><span class="md-toc-item md-toc-h3" data-ref="c1113"><a class="md-toc-inner" href="#header-c1113">获取摆盘   get_order_book 和 OrderBookHandlerBase</a></span><span class="md-toc-item md-toc-h3" data-ref="c1144"><a class="md-toc-inner" href="#header-c1144">获取分时数据   get_rt_data 和 RTDataHandlerBase</a></span><span class="md-toc-item md-toc-h3" data-ref="c1182"><a class="md-toc-inner" href="#header-c1182">获取经纪队列   get_broker_queue 和 BrokerHandlerBase</a></span></p></div><h1><a name='header-c6' class='md-header-anchor '></a>接口概要</h1><p>开放接口基于PC客户端获取数据，提供给用户使用。</p><p>开放接口分为<strong>低频接口</strong>、<strong>订阅接口</strong>和<strong>高频接口</strong>，以及<strong>回调处理基类</strong>：</p><p></p><p><strong>低频接口</strong>主要用来获取股票市场静态和全局的数据，让用户得到股票的基本信息，不允许高频调用。</p><p>如果要实时获取数据，则需要调用高频接口。</p><p></p><p><strong>订阅接口</strong>是用来管理高频接口使用额度，包括订阅、退订和查询额度。</p><p><em>订阅</em>：在使用高频接口前，需要订阅想要的数据。订阅成功后，则可以使用高频接口获取；订阅各类数据有额度限制：</p><p><strong>用户额度 &gt;= K线订阅数 * K线权重 + 逐笔订阅数 * 逐笔权重  + 报价订阅数 * 报价权重 + 摆盘订阅数 * 摆盘权重</strong></p><p><strong>订阅使用的额度不能超过用户额度，用户额度也就是订阅的上限为500个订阅单位</strong></p><table><thead><tr><th>订阅数据</th><th>额度权重（所占订阅单位）</th></tr></thead><tbody><tr><td>K线</td><td>2</td></tr><tr><td>逐笔</td><td>5（牛熊证为1）</td></tr><tr><td>报价</td><td>1</td></tr><tr><td>摆盘</td><td>5（牛熊证为1）</td></tr><tr><td>分时</td><td>2</td></tr><tr><td>经纪队列</td><td>5（牛熊证为1）</td></tr></tbody></table><p><em>查询额度</em>：用来查询现在各项额度占用情况。用户可以看到每一种类型数据都有订阅了哪些股票；然后利用退订操作来去掉不需要的股票数据。</p><p><em>退订</em>：用户可以退订指定股票和指定数据类型，空出额度。但是退订的时间限制为1分钟，即订阅某支股票某个订阅位1分钟之后才能退订。</p><p><strong>如果数据不订阅，直接调用高频接口则会返回失败。</strong>
订阅时可选择推送选项。推送开启后，程序就会持续收到客户端推送过来的行情数据。用户可以通过继承<strong>回调处理基类</strong>，并实现用户自己的子类来使用数据推送功能。</p><p><strong>高频接口</strong>可以获取实时数据，可以针对小范围内的股票频繁调用；比如需要跟踪某个股票的逐笔和摆盘变化等；在调用之前需要将频繁获取的数据订阅注册。</p><p><strong>回调处理基类</strong>用于实现数据推送功能，用户在此基类上实现子类并实例化后，当客户端不断推送数据时，程序就会调用对应的对象处理。</p><p></p><h1><a name='header-c63' class='md-header-anchor '></a>接口列表</h1><h2><a name='header-c64' class='md-header-anchor '></a>上下文控制</h2><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><span><span>​</span>x</span></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">start</span>() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-comment"># 开启异步数据接收</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">stop</span>() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 停止异步数据接收</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">set_handler</span>(<span class="cm-variable">handler</span>) <span class="cm-comment"># 设置用于异步处理数据的回调对象</span></span></pre></div></div></div></div></div></div></div></pre><h2><a name='header-c66' class='md-header-anchor '></a>低频数据接口</h2><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_trading_days</span>(<span class="cm-variable">market</span>, <span class="cm-variable">start_date</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">end_date</span>=<span class="cm-builtin">None</span>)  <span class="cm-comment"># 获取交易日</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_stock_basicinfo</span>(<span class="cm-variable">market</span>, <span class="cm-variable">stock_type</span>=<span class="cm-string">'STOCK'</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 获取股票信息</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_history_kline</span>(<span class="cm-variable">code</span>, <span class="cm-variable">start</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">end</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">ktype</span>=<span class="cm-string">'K_DAY'</span>, <span class="cm-variable">autype</span>=<span class="cm-string">'qfq'</span>)  <span class="cm-comment"># 获取历史K线</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_autype_list</span>(<span class="cm-variable">code_list</span>) &nbsp; &nbsp;  <span class="cm-comment"># 获取复权因子</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_market_snapshot</span>(<span class="cm-variable">code_list</span>)  <span class="cm-comment"># 获取市场快照</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_plate_list</span>(<span class="cm-variable">market</span>, <span class="cm-variable">plate_class</span>) &nbsp; &nbsp; &nbsp;  <span class="cm-comment">#获取板块集合下的子板块列表</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_plate_stock</span>(<span class="cm-variable">market</span>, <span class="cm-variable">stock_code</span>) &nbsp; &nbsp; &nbsp;  <span class="cm-comment">#获取板块下的股票列表</span></span></pre></div></div></div></div></div></div></div></pre><h2><a name='header-c68' class='md-header-anchor '></a>订阅接口</h2><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">subscribe</span>(<span class="cm-variable">stock_code</span>, <span class="cm-variable">data_type</span>, <span class="cm-variable">push</span>=<span class="cm-builtin">False</span>) <span class="cm-comment"># 订阅</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">unsubscribe</span>(<span class="cm-variable">stock_code</span>, <span class="cm-variable">data_type</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 退订</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">query_subscription</span>() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 查询订阅</span></span></pre></div></div></div></div></div></div></div></pre><h2><a name='header-c71' class='md-header-anchor '></a>高频数据接口</h2><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_stock_quote</span>(<span class="cm-variable">code_list</span>) <span class="cm-comment">#  获取报价</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_rt_ticker</span>(<span class="cm-variable">code</span>, <span class="cm-variable">num</span>) &nbsp; <span class="cm-comment"># 获取逐笔</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_cur_kline</span>(<span class="cm-variable">code</span>, <span class="cm-variable">num</span>, <span class="cm-variable">ktype</span>=<span class="cm-string">' K_DAY'</span>, <span class="cm-variable">autype</span>=<span class="cm-string">'qfq'</span>) <span class="cm-comment"># 获取当前K线</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_order_book</span>(<span class="cm-variable">code</span>) &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 获取摆盘</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_rt_data</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-comment">#获取分时数据</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_broker_queue</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment">#获取经纪队列</span></span></pre></div></div></div></div></div></div></div></pre><h2><a name='header-c73' class='md-header-anchor '></a>回调处理基类</h2><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right" style="display: none;"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">StockQuoteHandlerBase</span> <span class="cm-comment"># 报价处理基类</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">OrderBookHandlerBase</span>  <span class="cm-comment"># 摆盘处理基类</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">CurKlineHandlerBase</span> &nbsp; <span class="cm-comment"># 实时K线处理基类</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">TickerHandlerBase</span> &nbsp; &nbsp; <span class="cm-comment"># 逐笔处理基类</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">RTDataHandlerBase</span> &nbsp; &nbsp; <span class="cm-comment"># 分时数据处理基类</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">BrokerHandlerBase</span> &nbsp; &nbsp; <span class="cm-comment"># 经纪队列处理基类</span></span></pre></div></div></div></div></div></div></div></pre><p></p><h1><a name='header-c77' class='md-header-anchor '></a>接口说明</h1><h2><a name='header-c79' class='md-header-anchor '></a>参数类型定义</h2><p><strong>市场标识</strong> market，（字符串类型）： </p><table><thead><tr><th>股票市场</th><th>标识</th></tr></thead><tbody><tr><td>港股</td><td>&quot;HK&quot;</td></tr><tr><td>美股</td><td>&quot;US&quot;</td></tr><tr><td>沪股</td><td>&quot;SH&quot;</td></tr><tr><td>深股</td><td>&quot;SZ&quot;</td></tr><tr><td>香港期货</td><td>&quot;HK_FUTURE&quot;</td></tr></tbody></table><p></p><p><strong>证券类型</strong> stock_type，（字符串类型）：<br/></p><table><thead><tr><th>股票类型</th><th>标识</th></tr></thead><tbody><tr><td>正股</td><td>&quot;STOCK&quot;</td></tr><tr><td>指数</td><td>&quot;IDX&quot;</td></tr><tr><td>ETF基金</td><td>&quot;ETF&quot;</td></tr><tr><td>涡轮牛熊</td><td>&quot;WARRANT&quot;</td></tr><tr><td>债券</td><td>&quot;BOND&quot;</td></tr></tbody></table><p></p><p><strong>复权类型</strong>autype，（字符串类型）：</p><table><thead><tr><th>复权类型</th><th>标识</th></tr></thead><tbody><tr><td>前复权</td><td>&quot;qfq&quot;</td></tr><tr><td>后复权</td><td>&quot;hfq&quot;</td></tr><tr><td>不复权</td><td>None</td></tr></tbody></table><p></p><p><strong>K线类型</strong>，（字符串类型）： </p><table><thead><tr><th>K线类型</th><th>标识</th></tr></thead><tbody><tr><td>1分K</td><td>&quot;K_1M&quot;</td></tr><tr><td>5分K</td><td>&quot;K_5M&quot;</td></tr><tr><td>15分K</td><td>&quot;K_15M&quot;</td></tr><tr><td>30分K</td><td>&quot;K_30M&quot;</td></tr><tr><td>60分K</td><td>&quot;K_60M&quot;</td></tr><tr><td>日K</td><td>&quot;K_DAY&quot;</td></tr><tr><td>周K</td><td>&quot;K_WEEK&quot;</td></tr><tr><td>月K</td><td>&quot;K_MON&quot;</td></tr></tbody></table><p></p><p><strong>订阅数据类型</strong>，（字符串类型） </p><table><thead><tr><th>订阅类型</th><th>标识</th></tr></thead><tbody><tr><td>逐笔</td><td>&quot;TICKER&quot;</td></tr><tr><td>报价</td><td>&quot;QUOTE&quot;</td></tr><tr><td>摆盘</td><td>&quot;ORDER_BOOK&quot;</td></tr><tr><td>1分K</td><td>&quot;K_1M&quot;</td></tr><tr><td>5分K</td><td>&quot;K_5M&quot;</td></tr><tr><td>15分K</td><td>&quot;K_15M&quot;</td></tr><tr><td>30分K</td><td>&quot;K_30M&quot;</td></tr><tr><td>60分K</td><td>&quot;K_60M&quot;</td></tr><tr><td>日K</td><td>&quot;K_DAY&quot;</td></tr><tr><td>周K</td><td>&quot;K_WEEK&quot;</td></tr><tr><td>月K</td><td>&quot;K_MON&quot;</td></tr><tr><td>分时</td><td>&quot;RT_DATA&quot;</td></tr><tr><td>经纪队列</td><td>&quot;BROKER&quot;</td></tr></tbody></table><p></p><p><strong>板块分类类型</strong> ，（字符串类型）：</p><table><thead><tr><th>板块分类</th><th>标识</th></tr></thead><tbody><tr><td>所有板块</td><td>&quot;ALL&quot;</td></tr><tr><td>行业分类</td><td>&quot;INDUSTRY&quot;</td></tr><tr><td>地域分类</td><td>&quot;REGION&quot;</td></tr><tr><td>概念分类</td><td>&quot;CONCEPT&quot;</td></tr></tbody></table><p></p><p><strong>股票代码模式</strong>为：“ 市场+原始代码&quot;
例如，“HK.00700”, “SZ.000001”, “US.AAPL”</p><p></p><p><strong>注意，原始代码部分的字符串必须和客户端显示的完全匹配</strong>，比如：
腾讯为“HK.00700”，而不能是“HK.700”</p><p></p><p><strong>对于用户来说接口会返回两个值</strong>
ret_code：调用执行返回状态，0为成功，其它为失败
ret_data：</p><table><thead><tr><th>ret_code</th><th>ret_data</th></tr></thead><tbody><tr><td>成功</td><td>ret_data为实际数据</td></tr><tr><td>失败</td><td>ret_data为错误描述字符串</td></tr></tbody></table><h2><a name='header-c267' class='md-header-anchor '></a>错误码说明</h2><table><thead><tr><th>错误码</th><th>错误说明</th></tr></thead><tbody><tr><td>0</td><td>无错误</td></tr><tr><td>400</td><td>未知错误</td></tr><tr><td>401</td><td>版本不支持</td></tr><tr><td>402</td><td>股票未找到</td></tr><tr><td>403</td><td>协议号不支持</td></tr><tr><td>404</td><td>参数错误</td></tr><tr><td>405</td><td>频率错误（请求过快）</td></tr><tr><td>406</td><td>订阅达到上限</td></tr><tr><td>407</td><td>未订阅</td></tr><tr><td>408</td><td>未满足反订阅时间限制</td></tr><tr><td>501</td><td>服务器忙</td></tr><tr><td>502</td><td>超时</td></tr><tr><td>503</td><td>网络错误</td></tr></tbody></table><p></p><h2><a name='header-c314' class='md-header-anchor '></a>详细说明</h2><h3><a name='header-c315' class='md-header-anchor '></a>实例化上下文对象</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">quote_ctx</span> = <span class="cm-variable">OpenQuoteContext</span>(<span class="cm-variable">host</span>=<span class="cm-string">'127.0.0.1'</span>, <span class="cm-variable">port</span>=<span class="cm-number">11111</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：创建上下文，建立网络连接
<strong>参数</strong>:
<strong>host</strong>：网络连接地址
<strong>sync_port</strong>：网络连接端口，用于同步通信。
<strong>async_port</strong>：网络连接端口，用于异步通信，接收客户端的数据推送。</p><p></p><h3><a name='header-c326' class='md-header-anchor '></a>启动推送接收 start</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">quote_ctx</span>.<span class="cm-property">start</span>()</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：启动推送接收线程，异步接收客户端推送的数据。</p><p></p><h3><a name='header-c332' class='md-header-anchor '></a>停止推送接收 stop</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">quote_ctx</span>.<span class="cm-property">stop</span>()</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：停止推送接收线程，不再接收客户端推送的数据。</p><p></p><h3><a name='header-c338' class='md-header-anchor '></a>设置异步回调处理对象 set_handler</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">quote_ctx</span>.<span class="cm-property">set_handler</span>(<span class="cm-variable">handler</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：设置回调处理对象，用于接收线程在收到数据后调用。用户应该将自己实现的回调对象设置，以便实现事件驱动。</p><p>handler必须是以下几种类的子类对象：</p><table><thead><tr><th>类名</th><th>说明</th></tr></thead><tbody><tr><td><strong>StockQuoteHandlerBase</strong></td><td>报价处理基类</td></tr><tr><td><strong>OrderBookHandlerBase</strong></td><td>摆盘处理基类</td></tr><tr><td><strong>CurKlineHandlerBase</strong></td><td>实时K线处理基类</td></tr><tr><td><strong>TickerHandlerBase</strong></td><td>逐笔处理基类</td></tr><tr><td><strong>RTDataHandlerBase</strong></td><td>分时数据处理基类</td></tr><tr><td><strong>BrokerHandlerBase</strong></td><td>经纪队列处理基类</td></tr></tbody></table><p></p><h3><a name='header-c369' class='md-header-anchor '></a>获取交易日 get_trading_days</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_trading_days</span>(<span class="cm-variable">market</span>, <span class="cm-variable">start_date</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">end_date</span>=<span class="cm-builtin">None</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：取指定市场，某个日期时间段的交易日列表</p><p><strong>参数</strong>：
<strong>market</strong>: 市场标识
<strong>start_date</strong>: 起始日期;  string类型，格式YYYY-MM-DD，仅指定到日级别即可，默认值None表示最近一年前的日期
<strong>end_date</strong>: 结束日期;  string类型，格式YYYY-MM-DD，仅指定到日级别即可，取默认值None表示取当前日期</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为日期列表（每个日期是string类型），如果指定时间段中无交易日，则ret_data为空列表。</p><p><strong>失败情况</strong>：</p><ol><li>市场标识不合法</li><li>起止日期输入不合法</li><li>客户端内部或网络错误</li></ol><p></p><h3><a name='header-c398' class='md-header-anchor '></a>获取股票信息  get_stock_basicinfo</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_stock_basicinfo</span>(<span class="cm-variable">market</span>, <span class="cm-variable">stock_type</span>=<span class="cm-string">'STOCK'</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：取符合市场和股票类型条件的股票简要信息</p><p><strong>参数</strong>：
<strong>market</strong>: 市场标识, string，例如，”HK”，”US”；具体见市场标识说明
<strong>stock_type</strong>: 证券类型, string, 例如，”STOCK”，”ETF”；具体见证券类型说明</p><p><strong>证券类型</strong> stock_type，（字符串类型）： </p><table><thead><tr><th>股票类型</th><th>标识</th></tr></thead><tbody><tr><td>正股</td><td>&quot;STOCK&quot;</td></tr><tr><td>指数</td><td>&quot;IDX&quot;</td></tr><tr><td>ETF基金</td><td>&quot;ETF&quot;</td></tr><tr><td>涡轮牛熊</td><td>&quot;WARRANT&quot;</td></tr><tr><td>债券</td><td>&quot;BOND&quot;</td></tr></tbody></table><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无符合条件数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为一个dataframe，其中包括：
<strong>code</strong>：股票代码；string，例如： ”HK.00700”，“US.AAPL” 
<strong>name</strong>：股票名称；string 
<strong>lot_size</strong>：每手股数；int 
<strong>stock_type</strong>：股票类型；string，例如： ”STOCK”，”ETF” 
<strong>stock_child_type</strong>: 股票子类型；仅支持窝轮，其他为0，string，例如：&quot;BEAR&quot;，&quot;BULL&quot; 
<strong>owner_stock_code</strong>：所属正股；仅支持窝轮，其他为0 
<strong>listing_date</strong>: 上市日期： str </p><p><strong>失败情况</strong>：</p><ol><li>市场或股票类型不合法 </li><li>客户端内部或网络错误</li></ol><p></p><h3><a name='header-c450' class='md-header-anchor '></a>获取复权因子 get_autype_list</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_autype_list</span>(<span class="cm-variable">code_list</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取复权因子数据 
<strong>参数</strong>：
<strong>code_list</strong>: 股票代码列表，例如，HK.00700，US.AAPL</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串； 
客户端无符合条件数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为一个dataframe，其中包括： 
<strong>code</strong>：股票代码，string，例如： ”HK.00700”，“US.AAPL” 
<strong>ex_div_date</strong>：除权除息日，string类型，格式YYYY-MM-DD 
<strong>split_ratio</strong>：拆合股比例 double，例如，对于5股合1股为1/5，对于1股拆5股为5/1 
<strong>per_cash_div</strong>：每股派现；double 
<strong>per_share_div_ratio</strong>：每股送股比例；	double 
<strong>per_share_trans_ratio</strong>：每股转增股比例；	double 
<strong>allotment_ratio</strong>：	每股配股比例；double 
<strong>allotment_price</strong>：配股价；double 
<strong>stk_spo_ratio</strong>： 增发比例：double 
<strong>stk_spo_price</strong>  增发价格：double 
<strong>forward_adj_factorA</strong>：前复权因子A；double 
<strong>forward_adj_factorB</strong>：前复权因子B；double 
<strong>backward_adj_factorA</strong>：后复权因子A；double 
<strong>backward_adj_factorB</strong>：后复权因子B；double 
返回数据中不一定包含所有codelist中的代码，调用方自己需要检查，哪些股票代码是没有返回复权数据的，未返回复权数据的股票说明没有找到相关信息。 </p><p><strong>复权价格 = 复权因子A  * 价格 + 复权因子B</strong> </p><p><strong>失败情况</strong>： 
1．	Codelist中股票代码不合法 
2．	客户端内部或网络错误 </p><p></p><h3><a name='header-c486' class='md-header-anchor '></a>获取历史K线 get_history_kline</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_history_kline</span>(<span class="cm-variable">code</span>, <span class="cm-variable">start</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">end</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">ktype</span>=<span class="cm-string">'K_DAY'</span>, <span class="cm-variable">autype</span>=<span class="cm-string">'qfq'</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>： 获取指定股票K线历史数据 
<strong>参数</strong>： 
<strong>code</strong>：股票代码 
<strong>start</strong> ：开始时间, string; YYYY-MM-DD；为空时取去当前时间; 
<strong>end</strong>  ： 结束时间, string; YYYY-MM-DD；为空时取当前时间; 
<strong>ktype</strong> ：k线类型，默认为日K 
<strong>autype</strong>  复权类型，string；”qfq”-前复权，”hfq”-后复权，None-不复权，默认为”qfq” </p><p>开始结束时间按照闭区间查询，时间查询以k线时间time_key作为比较标准。即满足 
start&lt;=Time_key&lt;=end条件的k线作为返回内容，k线时间time_key的设定标准在返回值中说明 </p><p><strong>返回</strong>： 
ret_code失败时，ret_data返回为错误描述字符串； 
客户端无符合条件数据时，ret_code为成功，返回None<br/></p><p>正常情况下返回K线数据为一个DataFrame包含: 
<strong>code</strong>： 股票代码；string 
<strong>time_key</strong>：  K线时间 string  “YYYY-MM-DD HH:mm:ss” 
<strong>open</strong>： 开盘价；double 
<strong>high</strong>： 最高价；double 
<strong>close</strong>： 收盘价；double 
<strong>low</strong>： 最低价：double 
<strong>volume</strong>： 成交量；long 
<strong>turnover</strong> ：成交额；double </p><p>对于日K线，time_key为当日时间具体到日，比如说2016-12-23日的日K，K线时间为” 2016-12-23 00:00:00” </p><p>对于分K线，time_key为当日时间具体到分，例如，
1分K，覆盖时间为9：35：00到9：35：59的分K，K线时间time_key为”2016-12-23 09:36:00” 
5分K，覆盖时间为10：05：00到10：09：59的5分K，K线时间time_key为”2016-12-23 10:10:00” 
15分K，覆盖时间为10：00：00到10：14：59的15分K，K线时间time_key为”2016-12-23 10:15:00” 
30分K，覆盖时间为10：00：00到10：29：59的30分K，K线时间time_key为” 2016-12-23 10:30:00” 
60分K，覆盖时间为10：30：00到11：29：59的60分K，K线时间time_key为” 2016-12-23 11:30:00” </p><p>对于周K线，12月19日到12月25日的周K线，K线时间time_key为” 2016-12-19 00:00:00”<br/></p><p>对于月K线，12月的月K线时间time_key为” 2016-12-01 00:00:00”，即为当月1日时间 </p><p><strong>失败情况</strong>: </p><ol><li>股票代码不合法 </li><li>PLS接口返回错误<br/></li></ol><p></p><h3><a name='header-c537' class='md-header-anchor '></a>获取市场快照 get_market_snapshot</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_market_snapshot</span>(<span class="cm-variable">code_list</span>):</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：一次性获取最近当前股票列表的快照数据（每日变化的信息），该接口对股票个数有限制，一次最多传入200只股票，频率限制每5秒一次
<strong>参数</strong>：
<strong>code_list</strong>: 股票代码列表，例如，HK.00700，US.AAPL
传入的codelist只允许包含1种股票类型。
<strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无符合条件数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为一个dataframe，其中包括：</p><p><strong>code</strong> ：股票代码；string
<strong>update_time</strong>：	更新时间(yyyy-MM-dd HH:mm:ss)；string 
<strong>last_price</strong> ： 	 最新价格；float 
<strong>open_price</strong>：	 今日开盘价；float 
<strong>high_price</strong>：	 最高价格；float 
<strong>low_price</strong>：	     最低价格；float 
<strong>prev_close_price</strong>：	昨收盘价格；float 
<strong>volume</strong>：	成交数量； long 
<strong>turnover</strong>：	成交金额；float 
<strong>turnover_rate</strong>：	换手率；float 
<strong>suspension</strong>：	  是否停牌(True表示停牌)；bool 
<strong>listing_date</strong> ：  上市日期 (yyyy-MM-dd)；string 
<strong>circular_market_val</strong>：  流通市值；float 
<strong>total_market_val</strong>:		  总市值；float 
<strong>wrt_valid</strong>： 		是否是窝轮；bool 
<strong>wrt_conversion_ratio</strong>:		换股比率；float 
<strong>wrt_type</strong>：		窝轮类型；1=认购证 2=认沽证 3=牛证 4=熊证 string 
<strong>wrt_strike_price</strong>：		行使价格；float 
<strong>wrt_maturity_date</strong>:		格式化窝轮到期时间； string 
<strong>wrt_end_trade</strong>:		格式化窝轮最后交易时间；string 
<strong>wrt_code</strong>:		窝轮对应的正股；string 
<strong>wrt_recovery_price</strong>:		窝轮回收价；float 
<strong>wrt_street_vol</strong>:		窝轮街货量；float 
<strong>wrt_issue_vol</strong>:		窝轮发行量；float 
<strong>wrt_street_ratio</strong>:		窝轮街货占比；float 
<strong>wrt_delta</strong>: 		窝轮对冲值；float 
<strong>wrt_implied_volatility</strong>:		窝轮引伸波幅；float 
<strong>wrt_premium</strong>:		窝轮溢价；float 
<strong>lot_size</strong>：每手股数；int </p><p>返回DataFrame，包含上述字段</p><p><strong>窝轮类型</strong> wrt_type，（字符串类型）： </p><table><thead><tr><th>窝轮类型</th><th>标识</th></tr></thead><tbody><tr><td>&quot;CALL&quot;</td><td>认购证</td></tr><tr><td>&quot;PUT&quot;</td><td>认沽证</td></tr><tr><td>&quot;BULL&quot;</td><td>牛证</td></tr><tr><td>&quot;BEAR&quot;</td><td>熊证</td></tr><tr><td>&quot;N/A&quot;</td><td>未知或服务器没相关数据</td></tr></tbody></table><p>返回数据量不一定与codelist长度相等， 用户需要自己判断</p><p><strong>调用频率限制：</strong> 
<strong>5s一次</strong> </p><p><strong>失败情况</strong>: </p><ol><li>Codelist中股票代码不合法 </li><li>Codelist长度超过规定数量 </li><li>客户端内部或网络错误 </li><li>传入的codelist包含多种股票类型 </li></ol><p></p><h3><a name='header-c623' class='md-header-anchor '></a>获取分时数据  get_rt_data</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_rt_data</span>(<span class="cm-variable">code</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取指定股票的分时数据</p><p><strong>参数</strong>：
<strong>code</strong>: 股票代码，例如，HK.00700，US.APPL</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串； 
客户端无符合条件数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为一个dataframe，其中包括： 
<strong>code</strong>: 股票代码： string 
<strong>time</strong>：时间；string 
<strong>data_status</strong>：数据状态；bool，正确为True，伪造为False 
<strong>opened_mins</strong>: 开盘多少分钟：int 
<strong>cur_price</strong>：当前价格：float 
<strong>last_close</strong>: 昨天收盘的价格，float 
<strong>avg_price</strong>: 平均价格，float 
<strong>volume</strong>: 成交量，float 
<strong>turnover</strong>:  成交额，float </p><p><strong>失败情况</strong>：</p><ol><li>code不合法 </li><li>code是未对RT_DATA类型订阅的股票<br/></li><li>客户端内部或网络错误 </li></ol><h3><a name='header-c657' class='md-header-anchor '></a>获取板块集合下的子板块列表 get_plate_list</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_plate_list</span>(<span class="cm-variable">market</span>, <span class="cm-variable">plate_class</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>： 获取板块集合下的子板块列表 
<strong>参数</strong>：
<strong>market</strong>：市场标识，注意这里不区分沪，深,输入沪或者深都会返回沪深市场的子板块（这个是和客户端保持一致的）
<strong>plate_class</strong> ：板块分类, string; 例如，&quot;ALL&quot;, &quot;INDUSTRY&quot;</p><p><strong>板块分类类型</strong> ，（字符串类型）：</p><table><thead><tr><th>板块分类</th><th>标识</th></tr></thead><tbody><tr><td>&quot;ALL&quot;</td><td>所有板块</td></tr><tr><td>&quot;INDUSTRY&quot;</td><td>行业分类</td></tr><tr><td>&quot;REGION&quot;</td><td>地域分类</td></tr><tr><td>&quot;CONCEPT&quot;</td><td>概念分类</td></tr></tbody></table><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串； 
客户端无符合条件数据时，ret_code为成功，返回None<br/></p><p>正常情况下返回K线数据为一个DataFrame包含: 
<strong>code</strong>： 板块代码；string 
<strong>plate_name</strong>： 板块名称；string 
<strong>plate_id</strong>: 板块ID：string 
港股美股市场的地域分类数据暂时为空 </p><p><strong>失败情况</strong>：</p><ol><li>市场标识不合法 </li><li>板块分类不合法 </li><li>客户端内部或网络错误 </li></ol><h3><a name='header-c704' class='md-header-anchor '></a>获取板块下的股票列表  get_plate_stock</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_plate_stock</span>(<span class="cm-variable">plate_code</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取特定板块下的股票列表,注意这里不区分沪，深,输入沪或者深都会返回沪深市场</p><p><strong>参数</strong>：
<strong>plate_code</strong>: 板块代码, string, 例如，”SH.BK0001”，”SH.BK0002”，先利用获取子版块列表函数获取子版块代码</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无符合条件数据时，ret_code为成功，ret_data返回None </p><p>正常情况下，ret_data为一个dataframe，其中包括： 
<strong>code</strong>：；股票代码：string，例如： ”SZ.000158”，“SZ.000401” 
<strong>lot_size</strong>：每手股数；int 
<strong>stock_name</strong>：股票名称；string，例如： ”天然乳品”，”大庆乳业” 
<strong>owner_market</strong>: 所属股票的市场，仅支持窝轮，其他为空，string 
<strong>stock_child_type</strong>: 股票子类型；仅支持窝轮，其他为0，string，例如：&quot;BEAR&quot;，&quot;BULL&quot; 
<strong>stock_type</strong>：股票类型：string, 例如，&quot;BOND&quot;, &quot;STOCK&quot; </p><table><thead><tr><th>股票类型</th><th>标识</th></tr></thead><tbody><tr><td>&quot;STOCK&quot;</td><td>正股</td></tr><tr><td>&quot;IDX&quot;</td><td>指数</td></tr><tr><td>&quot;ETF&quot;</td><td>ETF基金</td></tr><tr><td>&quot;WARRANT&quot;</td><td>涡轮牛熊</td></tr><tr><td>&quot;BOND&quot;</td><td>债券</td></tr></tbody></table><p><strong>股票子类型</strong> wrt_type，（字符串类型）：<br/></p><table><thead><tr><th>股票子类型</th><th>标识</th></tr></thead><tbody><tr><td>&quot;CALL&quot;</td><td>认购证</td></tr><tr><td>&quot;PUT&quot;</td><td>认沽证</td></tr><tr><td>&quot;BULL&quot;</td><td>牛证</td></tr><tr><td>&quot;BEAR&quot;</td><td>熊证</td></tr><tr><td>&quot;N/A&quot;</td><td>未知或服务器没相关数据</td></tr></tbody></table><p><strong>失败情况</strong>：</p><ol><li>市场或板块代码不合法，或者该板块不存在<br/></li><li>客户端内部或网络错误 </li></ol><h3><a name='header-c773' class='md-header-anchor '></a>获取经纪队列  get_broker_queue</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right" style="display: none;"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap "><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 186px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">bid_data</span>, <span class="cm-variable">ask_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_broker_queue</span>(<span class="cm-variable">code</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取股票的经纪队列</p><p><strong>参数</strong>：
<strong>code</strong>: 股票代码, string, 例如，”HK.00700”</p><p><strong>返回</strong>：
ret_code失败时，bid_data返回为错误描述字符串； 
客户端无符合条件数据时，ret_code为成功，ask_data, bid_data返回None 
正常情况下，ask_data, bid_data均为dataframe， 
其中bid_data是买盘的数据，包括： 
<strong>bid_broker_id</strong>: 经纪买盘id；int 
<strong>bid_broker_name</strong>：经纪买盘名称；string，例如： ”高盛”，”法巴” 
<strong>bid_broker_pos</strong>: 经纪档位：int, 例如：0，1 </p><p>其中ask_data是卖盘的数据，包括： 
<strong>ask_broker_id</strong>：经纪卖盘id；int 
<strong>ask_broker_name</strong>：经纪卖盘名称；string，例如： ”高盛”，”法巴” 
<strong>ask_broker_pos</strong>: 经纪档位：int, 例如：0，1 </p><p><strong>失败情况</strong>： </p><ol><li>股票代码不合法，不存在 </li><li>客户端内部或网络错误 </li></ol><h3><a name='header-c804' class='md-header-anchor '></a>获取牛牛程序全局状态  get_global_state</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">state_dict</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_global_state</span>() </span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取牛牛程序全局状态 </p><p><strong>参数</strong>：无</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串； 
客户端无符合条件数据时，ret_code为成功，ret_data返回None<br/></p><p>正常情况下，ret_data为dict，包括：
<strong>Trade_Logined</strong>: 是否登陆交易服务器,int(0|1), 1 表示登陆，0表示未登陆<br/>
<strong>Quote_Logined</strong>：是否登陆行情服务器,int(0|1), 1 表示登陆，0表示未登陆 
<strong>Market_HK</strong>: 港股主板市场状态,int,字段定义详见下表 
<strong>Market_US</strong>: 美股Nasdaq市场状态,int, 字段定义详见下表 
<strong>Market_SH</strong>: 沪市状态,int,字段定义详见下表 
<strong>Market_SZ</strong>: 深市状态,int,字段定义详见下表 
<strong>Market_HKFuture</strong>: 港股期货市场状态,int,字段定义详见下表 </p><p><strong>市场字段说明</strong> ： </p><table><thead><tr><th>市场状态</th><th>说明</th></tr></thead><tbody><tr><td>0</td><td>未开盘</td></tr><tr><td>1</td><td>竞价交易（港股）</td></tr><tr><td>2</td><td>早盘前等待开盘（港股）</td></tr><tr><td>3</td><td>早盘（港股）</td></tr><tr><td>4</td><td>午休（A股、港股）</td></tr><tr><td>5</td><td>午盘（A股、港股）/ 盘中（美股）</td></tr><tr><td>6</td><td>交易日结束（A股、港股）/ 已收盘（美股）</td></tr><tr><td>8</td><td>盘前开始（美股）</td></tr><tr><td>9</td><td>盘前结束（美股）</td></tr><tr><td>10</td><td>盘后开始（美股）</td></tr><tr><td>11</td><td>盘后结束（美股）</td></tr><tr><td>12</td><td>内部状态，用于交易日切换</td></tr><tr><td>13</td><td>夜市交易中（港期货）</td></tr><tr><td>14</td><td>夜市收盘（港期货）</td></tr><tr><td>15</td><td>日市交易中（港期货）</td></tr><tr><td>16</td><td>日市午休（港期货）</td></tr><tr><td>17</td><td>日市收盘（港期货）</td></tr><tr><td>18</td><td>日市等待开盘（港期货）</td></tr><tr><td>19</td><td>港股盘后竞价</td></tr></tbody></table><p></p><p><strong>失败情况</strong>：</p><ol><li>客户端内部或网络错误 </li></ol><h3><a name='header-c895' class='md-header-anchor '></a>订阅 subscribe</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>,<span class="cm-variable">ret_data</span>= <span class="cm-variable">quote_ctx</span>.<span class="cm-property">subscribe</span>(<span class="cm-variable">stock_code</span>, <span class="cm-variable">data_type</span>, <span class="cm-variable">push</span>=<span class="cm-builtin">False</span>) </span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：订阅注册需要的实时信息，指定股票和订阅的数据类型即可： 
<strong>参数</strong>： 
<strong>stock_code</strong>: 需要订阅的股票代码 
<strong>data_type</strong>: 需要订阅的数据类型 
<strong>push</strong>: 推送选项，默认不推送 
<strong>返回</strong>： 
ret_code失败时，ret_data返回为错误描述字符串； 
ret_code为成功，ret_data返回None 
如果指定内容已订阅，则直接返回成功 </p><p><strong>失败情况</strong>: </p><ol><li>股票代码不合法，不存在 </li><li>数据类型不合法 </li><li>订阅额度已满，参考订阅额度表 </li><li>客户端内部或网络错误 </li></ol><p></p><h3><a name='header-c924' class='md-header-anchor '></a>退订 unsubscribe</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;">ret_code,ret_data = quote_ctx.unsubscribe(stock_code, data_type, unpush=True)  </span></pre></div></div></div></div></div></div></div></pre><p>ret_code,ret_data = unsubscribe(stock_code, data_type, unpush=True) 
<strong>功能</strong>：退订注册的实时信息，指定股票和订阅的数据类型即可
<strong>参数</strong>：
<strong>stock_code</strong>: 需要退订的股票代码 
<strong>data_type</strong>: 需要退订的数据类型 </p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串； 
ret_code为成功，ret_data返回None 
如果指定内容已退订，则直接返回成功 </p><p><strong>失败情况</strong>:</p><ol><li><p>股票代码不合法，不存在</p></li><li><p>数据类型不合法</p></li><li><p>内容订阅后不超过60s，就退订</p></li><li><p>客户端内部或网络错误</p><p>​</p></li></ol><h3><a name='header-c954' class='md-header-anchor '></a>查询订阅 query_subscription</h3><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">query_subscription</span>(<span class="cm-variable">query</span>=<span class="cm-number">0</span>) </span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：查询已订阅的实时信息
<strong>参数</strong>： 
<strong>query</strong>: 需要查询的类型，int, 0表示当前查询的socket,非0表示查询所有socket的订阅状态 
<strong>返回</strong>： 
字典类型，已订阅类型为主键，值为订阅该类型的股票，例如 </p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;">{ <span class="cm-error">‘</span><span class="cm-variable">QUOTE</span><span class="cm-error">’</span>: [<span class="cm-error">‘</span><span class="cm-variable">HK</span><span class="cm-number">.00700</span><span class="cm-error">’</span>, <span class="cm-error">‘</span><span class="cm-variable">SZ</span><span class="cm-number">.000001</span><span class="cm-error">’</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;">  <span class="cm-error">‘</span><span class="cm-variable">TICKER</span><span class="cm-error">’</span>: [<span class="cm-error">‘</span><span class="cm-variable">HK</span><span class="cm-number">.00700</span><span class="cm-error">’</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;">  <span class="cm-error">‘</span><span class="cm-variable">K_1M</span><span class="cm-error">’</span>: [<span class="cm-error">‘</span><span class="cm-variable">HK</span><span class="cm-number">.00700</span><span class="cm-error">’</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;">  <span class="cm-comment">#无股票订阅摆盘和其它类型分K</span></span></pre><pre class=""><span style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div></div></div></pre><p><strong>失败情况</strong>:
客户端内部或网络错误</p><p></p><h3><a name='header-c969' class='md-header-anchor '></a>获取报价   get_stock_quote 和 StockQuoteHandlerBase</h3><p>对于同步请求使用<strong>get_stock_quote</strong>直接得到报价</p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_stock_quote</span>(<span class="cm-variable">code_list</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取订阅股票报价的实时数据，有订阅要求限制 
<strong>参数</strong>： 
<strong>code_list</strong>: 股票代码列表，例如，HK.00700，US.AAPL 
传入的codelist只允许包含1种股票类型的股票。 
必须确保code_list中的股票均订阅成功后才能够执行 </p><p><strong>返回</strong>： 
ret_code失败时，ret_data返回为错误描述字符串； 
客户端无符合条件数据时，ret_code为成功，返回None 
正常情况下，ret_data为一个dataframe，其中包括：</p><p><strong>code</strong> ：股票代码；string
<strong>data_date</strong>:      日期： str
<strong>data_time</strong>:      时间：str
<strong>last_price</strong> ： 	 最新价格；float 
<strong>open_price</strong>：	 今日开盘价；float 
<strong>high_price</strong>：	 最高价格；float 
<strong>low_price</strong>：	     最低价格；float 
<strong>prev_close_price</strong>：	昨收盘价格；float 
<strong>volume</strong>：	成交数量； long 
<strong>turnover</strong>：	成交金额；float 
<strong>turnover_rate</strong>：	换手率；float 
<strong>amplitude</strong> :     振幅：int
<strong>suspension</strong>：	  是否停牌(True表示停牌)；bool 
<strong>listing_date</strong> ：  上市日期 (yyyy-MM-dd)；string </p><p><strong>失败情况</strong>: </p><ol><li>codelist中股票代码不合法 </li><li>codelist包含未对QUOTE类型订阅的股票 </li><li>客户端内部或网络错误 </li><li>传入的codelist包含多种股票类型 </li></ol><p>对于异步推送数据需要使用<strong>StockQuoteHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">StockQuoteTest</span>(<span class="cm-variable">StockQuoteHandlerBase</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>(<span class="cm-variable">StockQuoteTest</span>,<span class="cm-variable-2">self</span>).<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回了报价信息，格式与get_stock_quote一样</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"StockQuoteTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"StockQuoteTest "</span>, <span class="cm-variable">content</span>) <span class="cm-comment"># StockQuoteTest自己的处理逻辑</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span></span></pre></div></div></div></div></div></div></div></pre><p></p><h3><a name='header-c1020' class='md-header-anchor '></a>获取逐笔   get_rt_ticker 和 TickerHandlerBase</h3><p>对于同步请求使用<strong>get_rt_ticker</strong>直接得到逐笔</p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_rt_ticker</span>(<span class="cm-variable">code</span>, <span class="cm-variable">num</span>=<span class="cm-number">500</span>)</span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>： 获取指定股票的实时逐笔。取最近num个逐笔， 
<strong>参数</strong>： 
<strong>code</strong>: 股票代码，例如，HK.00700，US.AAPL 
<strong>num</strong>: 最近ticker个数(有最大个数限制，最近500个） </p><p><strong>返回</strong>： 
ret_code失败时，ret_data为错误描述字符串； 
客户端无符合条件数据时，ret为成功，ret_data返回None 
通常情况下，返回DataFrame，DataFrame每一行是一个逐笔记录，包含： 
<strong>stock_code</strong> 股票代码 
<strong>sequence</strong> 逐笔序号 
<strong>time</strong> 成交时间；string 
<strong>price</strong> 成交价格；double 
<strong>volume</strong> 成交数量（股数）；int 
<strong>turnover</strong> 成交金额；double 
<strong>ticker_direction</strong> 逐笔方向；int </p><p>ticker_direction:</p><table><thead><tr><th>逐笔标识</th><th>说明</th></tr></thead><tbody><tr><td>TT_BUY</td><td>外盘</td></tr><tr><td>TT_ASK</td><td>内盘</td></tr><tr><td>TT_NEUTRAL</td><td>中性盘</td></tr></tbody></table><p>返回的逐笔记录个数不一定与num指定的相等，客户端只会返回自己有的数据。 </p><p><strong>失败情况</strong>： </p><ol><li>code不合法 </li><li>code是未对TICKER类型订阅的股票 </li><li>客户端内部或网络错误 </li></ol><p>对于异步推送数据需要使用<strong>TickerHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">TickerTest</span>(<span class="cm-variable">TickerHandlerBase</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>(<span class="cm-variable">TickerTest</span>,<span class="cm-variable-2">self</span>).<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回了逐笔信息，格式与get_rt_ticker一样</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"TickerTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"TickerTest"</span>, <span class="cm-variable">content</span>)  <span class="cm-comment"># StockQuoteTest自己的处理逻辑</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span></span></pre></div></div></div></div></div></div></div></pre><p></p><h3><a name='header-c1076' class='md-header-anchor '></a>获取实时K线    get_cur_kline 和 CurKlineHandlerBase</h3><p>对于同步请求使用<strong>get_cur_kline</strong>直接得到实时K线 </p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_cur_kline</span>(<span class="cm-variable">code</span>, <span class="cm-variable">num</span>, <span class="cm-variable">ktype</span>=<span class="cm-string">'K_DAY'</span>, <span class="cm-variable">autype</span>=<span class="cm-string">'qfq'</span>)</span></pre></div></div></div></div></div></div></div></pre><p></p><p><strong>功能</strong>： 实时获取指定股票最近num个K线数据，最多1000根 
<strong>参数</strong>： 
<strong>code</strong> 股票代码 
<strong>ktype</strong> k线类型，和get_history_kline一样 
<strong>autype</strong>  复权类型，string；qfq-前复权，hfq-后复权，None-不复权，默认为qfq </p><p>对于实时K线数据最多取最近1000根 </p><p><strong>返回</strong>： 
ret_code失败时，ret_data为错误描述字符串； 
客户端无符合条件数据时，ret为成功，ret_data返回None 
通常情况下，返回DataFrame，DataFrame内容和get_history_kline一样 </p><p><strong>失败情况</strong>：</p><ol><li>code不合法 </li><li>该股票未对指定K线类型订阅 </li><li>客户端内部或网络错误 </li></ol><p>对于异步推送数据需要使用<strong>CurKlineHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">CurKlineTest</span>(<span class="cm-variable">CurKlineHandlerBase</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>(<span class="cm-variable">CurKlineTest</span>,<span class="cm-variable-2">self</span>).<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回了实时K线信息，格式除了与get_cur_kline所有字段外，还包含K线类型k_type</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"CurKlineTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"CurKlineTest"</span>, <span class="cm-variable">content</span>) <span class="cm-comment"># CurKlineTest自己的处理逻辑</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre></div></div></div></div></div></div></div></pre><p></p><h3><a name='header-c1113' class='md-header-anchor '></a>获取摆盘   get_order_book 和 OrderBookHandlerBase</h3><p>对于同步请求使用<strong>get_order_book</strong>直接得到摆盘 </p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_order_book</span>(<span class="cm-variable">code</span>) </span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取实时摆盘数据 
<strong>参数</strong>： 
<strong>code</strong>: 股票代码，例如，HK.00700，US.AAPL 
<strong>返回</strong>： 
ret_code失败时，ret_data为错误描述字符串； 
客户端无符合条件数据时，ret为成功，ret_data返回None 
通常情况下，返回字典 </p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;">{<span class="cm-error">‘</span><span class="cm-variable">stock_code</span><span class="cm-error">’</span>: <span class="cm-variable">stock_code</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> <span class="cm-error">‘</span><span class="cm-variable">Ask</span><span class="cm-error">’</span>:[ (<span class="cm-variable">ask_price1</span>, <span class="cm-variable">ask_volume1</span><span class="cm-error">，</span><span class="cm-variable">order_num</span>), (<span class="cm-variable">ask_price2</span>, <span class="cm-variable">ask_volume2</span>, <span class="cm-variable">order_num</span>),<span class="cm-error">…</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-error">‘</span><span class="cm-variable">Bid</span><span class="cm-error">’</span>: [ (<span class="cm-variable">bid_price1</span>, <span class="cm-variable">bid_volume1</span>, <span class="cm-variable">order_num</span>), (<span class="cm-variable">bid_price2</span>, <span class="cm-variable">bid_volume2</span>, <span class="cm-variable">order_num</span>),<span class="cm-error">…</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div></div></div></pre><p><strong>失败情况</strong>： </p><ol><li>code不合法 </li><li>该股票未对ORDER_BOOK类型订阅 </li><li>客户端内部或网络错误 </li></ol><p>对于异步推送数据需要使用<strong>OrderBookHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">OrderBookTest</span>(<span class="cm-variable">OrderBookHandlerBase</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>(<span class="cm-variable">OrderBookTest</span>,<span class="cm-variable-2">self</span>).<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回摆盘信息，格式与get_order_book一样</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"OrderBookTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"OrderBookTest"</span>, <span class="cm-variable">content</span>) <span class="cm-comment"># OrderBookTest自己的处理逻辑</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre></div></div></div></div></div></div></div></pre><p></p><h3><a name='header-c1144' class='md-header-anchor '></a>获取分时数据   get_rt_data 和 RTDataHandlerBase</h3><p>对于同步请求使用<strong>get_rt_data</strong>直接得到分时数据 </p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_rt_data</span>(<span class="cm-variable">code</span>) </span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取实时分时数据 
<strong>参数</strong>： 
<strong>code</strong>: 股票代码，例如，HK.00700，US.AAPL 
<strong>返回</strong>： 
ret_code失败时，ret_data为错误描述字符串； 
客户端无符合条件数据时，ret为成功，ret_data返回None 
通常情况下，返回 
<strong>time</strong> 时间 
<strong>data_status</strong> 数据状态 
<strong>opened_mins</strong>  开盘多少分钟 
<strong>cur_price</strong> 当前价格 
<strong>last_close</strong>  昨天收盘的价格 
<strong>avg_price</strong> 平均价格 
<strong>volume</strong> 成交量 
<strong>turnover</strong>  成交额 </p><p><strong>失败情况</strong>： </p><ol><li>code不合法 </li><li>该股票未对RT_DATA类型订阅 </li><li>客户端内部或网络错误 </li></ol><p>对于异步推送数据需要使用<strong>RTDataHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">RTDataTest</span>(<span class="cm-variable">RTDataHandlerBase</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>(<span class="cm-variable">RTDataTest</span>,<span class="cm-variable-2">self</span>).<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回分时数据，格式与get_rt_data一样</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"RTDataTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"RTDataTest"</span>, <span class="cm-variable">content</span>) </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre></div></div></div></div></div></div></div></pre><p></p><h3><a name='header-c1182' class='md-header-anchor '></a>获取经纪队列   get_broker_queue 和 BrokerHandlerBase</h3><p>对于同步请求使用<strong>get_broker_queue</strong>直接得到经纪队列 </p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_broker_queue</span>(<span class="cm-variable">code</span>)  </span></pre></div></div></div></div></div></div></div></pre><p><strong>功能</strong>：获取实时经纪队列 
<strong>参数</strong>： 
<strong>code</strong>: 股票代码，例如，HK.00700，US.AAPL 
<strong>返回</strong>：
ret_code失败时，ret_data为错误描述字符串； 
客户端无符合条件数据时，ret为成功，ret_data返回None 
通常情况下，返回 
bid_data是买盘的数据，包括： 
<strong>bid_broker_id</strong> 经纪卖盘id 
<strong>bid_broker_name</strong> 经纪卖盘名称 
<strong>bid_broker_pos</strong> 经纪档位 </p><p>ask_data是卖盘的数据 
<strong>ask_broker_id</strong> 经纪买盘id 
<strong>ask_broker_name</strong>  经纪买盘名称 
<strong>ask_broker_pos</strong> 经纪档位 </p><p><strong>失败情况</strong>： </p><ol><li>code不合法 </li><li>该股票未对BROKER类型订阅 </li><li>客户端内部或网络错误 </li></ol><p>对于异步推送数据需要使用<strong>BrokerHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences"><div class="code-tooltip md-tooltip-hide" align="right"></div> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"></div><div class="CodeMirror-vscrollbar"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-code"><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">BrokerTest</span>(<span class="cm-variable">BrokerHandlerBase</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">ask_content</span>, <span class="cm-variable">bid_content</span> = <span class="cm-builtin">super</span>(<span class="cm-variable">BrokerTest</span>, <span class="cm-variable-2">self</span>).<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回经纪队列，格式与get_broker_queue一样</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"BrokerTest: error, msg: %s %s "</span> <span class="cm-operator">%</span> <span class="cm-variable">ask_content</span> <span class="cm-operator">%</span> <span class="cm-variable">bid_content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">ask_content</span>, <span class="cm-variable">bid_content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"BrokerTest"</span>, <span class="cm-variable">ask_content</span>, <span class="cm-variable">bid_content</span>) </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">ask_content</span>, <span class="cm-variable">bid_content</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre></div></div></div></div></div></div></div></pre><p></p><p></p></div>
</body>
</html>